package Arithmetic;

public class priority {
    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        int c = 30;
        int d = 40;

        // 案例：运算符优先级
        boolean result = (a + b * c / d) > (a + b) && (c - d) < 0 ? true : false;

        // 打印中间结果以理解优先级
        int intermediate1 = b * c / d; // 先乘除
        int intermediate2 = a + intermediate1; // 再加
        int intermediate3 = a + b; // 加
        int intermediate4 = c - d; // 减
        boolean comparison1 = intermediate2 > intermediate3; // 关系运算
        boolean comparison2 = intermediate4 < 0; // 关系运算
        boolean logicalAnd = comparison1 && comparison2; // 逻辑与

        System.out.println("中间结果: b * c / d = " + intermediate1); // 15
        System.out.println("中间结果: a + (b * c / d) = " + intermediate2); // 25
        System.out.println("中间结果: a + b = " + intermediate3); // 30
        System.out.println("中间结果: c - d = " + intermediate4); // -10
        System.out.println("中间结果: (a + b * c / d) > (a + b) = " + comparison1); // false
        System.out.println("中间结果: (c - d) < 0 = " + comparison2); // true
        System.out.println("中间结果: ((a + b * c / d) > (a + b)) && ((c - d) < 0) = " + logicalAnd); // false
        System.out.println("最终结果: " + result); // false
    }
}
